<?php
/*------------------------------------------------------------------------
 # SM Slider - Version 1.1
 # Copyright (c) 2013 YouTech Company. All Rights Reserved.
 # @license - Copyrighted Commercial Software
 # Author: YouTech Company
 # Websites: http://www.magentech.com
-------------------------------------------------------------------------*/

$options = $this->getConfigObject();
$uniqued ='container_slider_'.rand().time();
$smarthelper= Mage::helper('slider/utils');
$list = $this->getProducts();
if(!empty($list)){
	echo $this->getScriptTags();?>
	<div id="<?php echo $uniqued; ?>" class="container-slider brand-slider">
		<div class="brand-slider-header">
			<div class="title-header page-title-slider">
				<?php echo $options->slider_title_text;?>
			</div>
			<?php if($options->anchor =="top"){?>
			<?php if($options->button_display == 1){?>
			<div class="page-button <?php echo $options->anchor;?> <?php echo $options->control;?>">
				<ul class="control-button">
					<li class="preview icon-angle-left"></li>
					<li class="next icon-angle-right"></li>
				</ul>		
			</div>
			<?php }}?>
		</div>	
		<div class="slider not-js cols-6 <?php echo $options->deviceclass_sfx; ?>">
			<div class="vpo-wrap">
				<div class="vp">
					<div class="vpi-wrap">
					<?php $i = 0; foreach($list as $item){ $i++;?>
						<?php if( $i%3 == 1){?>
						<div class="item">
						<?php }?>
							<div class="item-wrap">
								<div class="item-img item-height">
									<div class="item-img-info">
										<a href="<?php echo $item['link'];?>" <?php echo $smarthelper->getTargetAttr($options->product_links_target);?> onclick="javascript: return true";>
										<?php if( $options->product_source == "catalog" ){?>
											<img src="<?php echo $item['image'];?>" alt="<?php echo $item['title']; ?>" title="<?php echo $item['title']; ?>" />
										<?php }else{?>
											<img  src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$item['image'] ?>"  alt="<?php echo $item['title'] ?>" />	
										<?php }?>
										</a>
									</div>
								</div>						
							</div>
						<?php if( $i%3 == 0 || $i == count($list)){?>
						</div>
					<?php }}?>
					</div>
				</div>
			</div>
		</div>
	</div>
<?php }else {echo $this->__('Has no item to show!');}?>

<script type="text/javascript">
//<![CDATA[
    jQuery(document).ready(function($){
        $('#<?php echo $uniqued;?> .slider').responsiver({
            interval: <?php echo $options->delay;?>,
            speed: <?php echo $options->duration;?>,
            start: <?php echo $options->start -1;?>,
            step: <?php echo $options->scroll;?>,
            circular: true,
            preload: true,
			fx: 'slide',
            pause: 'hover',
            control:{
				prev: '#<?php echo $uniqued;?> .control-button li[class="preview icon-angle-left"]',
				next: '#<?php echo $uniqued;?> .control-button li[class="next icon-angle-right"]'
            },
			getColumns: function(element){
				var match = $(element).attr('class').match(/cols-(\d+)/);
				if (match[1]){
					var column = parseInt(match[1]);
				} else {
					var column = 1;
				}
				if (!column) column = 1;
				return column;
			}          
        });
    });
//]]>
</script>



